package com.brooks.demo;

/**
 * @author Maoyan
 * @data 2020/10/18 1i5:05
 * @Version 1.0.0
 */
public class TestLambda {
    //静态内部类
    static class Like2 implements Ilike {

        @Override
        public void lambda() {
            System.out.println("lambda2");
        }
    }
    public static void main(String[] args) {
        Ilike ilke = new Like1();
        ilke.lambda();

        ilke = new Like2();
        ilke.lambda();

        //局部内部类
        class Like3 implements Ilike {

            public void lambda() {
                System.out.println("lambda3");
            }
        }

        ilke = new Like3();
        ilke.lambda();

        //匿名内部类
        ilke = new Ilike() {
            @Override
            public void lambda() {
                System.out.println("lambda4");
            }
        };
        ilke.lambda();

        //用lambda简化
        ilke = ()->{
            System.out.println("lambda5");
        };

        ilke.lambda();
    }
}

interface Ilike{
    void lambda();
}

class Like1 implements Ilike {

    @Override
    public void lambda() {
        System.out.println("lambda1");
    }
}
